<div class="left-column">
        {assign var="avatarSrc" value=UploadImageFacade::resolveImagePath($user->avatar_id, "230x336")}
	<img src="{$avatarSrc}" alt="" class="avatar" width="230" height="336" />
        {if !Yii::app()->user->isGuest}
	<div class="user-menu">
		<ul>
                        {if ($isAuthor == true)}
			<li><a href="/user/update/{$user->user_id}">Редактировать страницу</a></li>
                        <li><a href="/user/updateAvatar/">Изменить фотографию</a></li>
			<li><a href="/post/create">Создать пост</a></li>
			<li><a href="/albums/{$user->user_id}">Добавить фото</a></li>
			<li><a href="/video/create">Добавить видео</a></li>
			<li><a href="{$baseUrl}/pet/create">Добавить любимца</a></li>
                        {else}
                        <li><a href="/message/send/{$user->user_id}">Отправить сообщение</a></li>
                        {if ($isFriend)}
                        <li><a href="/friend/delete/{$user->user_id}">Удалить из друзей</a></li>
                        {else}
                        <li><a href="/friend/add/{$user->user_id}">Добавить в друзья</a></li>
                        {/if}
                        {/if}
		</ul>
	</div>
        {/if}
        {if ($albumsCount > 0)}
	<div class="window">
		<div class="window-head">
			<p class="window-title">Фотоальбомы</p>
			<p class="window-info">(всего: {$albumsCount})</p>
			<a href="/albums/{$user->user_id}" class="window-link">все</a>
		</div>
		<div class="window-content">
                        {foreach from=$albums item=userAlbum}
                        {assign var="lastPhoto" value=UploadImageFacade::resolveImagePath(PhotoFacade::getLatestPhotoByAlbum($userAlbum->album_id)->src, "100x100")}
			<div class="record">
				<a href="/album/{$userAlbum->album_id}"><img src="{$lastPhoto}" alt=""></img></a>
				<p class="record-title"><a href="/album/{$userAlbum->album_id}">{$userAlbum->album->name}</a></p><br />
				<p class="record-info">фото: {PhotoFacade::getCountPhotosByAlbum($userAlbum->album_id)}</p>
				<a href="/album/{$userAlbum->album_id}" class="record-link">посмотреть</a>
			</div>
			<br />
                        {/foreach}			
		</div>
		<div class="window-bottom-left">
			<div class="window-bottom-right">
			</div>
		</div>
	</div>
        {/if}
        {userVideoWidget userId=$user->user_id count=3}
</div>
<div class="right-column">
<h1>
    {$user->surname} {$user->name}
    {if ($isAuthor)}
        <span>(это Вы)</span>
    {/if}
    {if UserFacade::userIsVet($user)}
        <small>ветеринар</small>
        <img class="vet-logo" src="/images/aibolit.gif" />
    {/if}
</h1>
<table class="info">
  <tbody>
        {if $user->birthdate}
        <tr>
          <td width="140">Дата рождения:</td>
          <td>{$user->birthdate|date_format:"%e.%m.%Y"}</td>
        </tr>
        {/if}
        {if $user->city}
        <tr>
          <td width="140">Город:</td>
          <td>{$user->city}</td>
        </tr>
        {/if}
        <tr><td><br/></td></tr>        
        <tr>
          <td width="140">Контакты:</td>
          <td></td>
        </tr>
        <tr><td><br/></td></tr>
        {if $user->mobile_phone}
        <tr>
          <td>Моб. телефон:</td>
          <td>{$user->mobile_phone}</td>
        </tr>
        {/if}
        {if $user->home_phone}
        <tr>
          <td>Дом. телефон:</td>
          <td>{$user->home_phone}</td>
        </tr>
        {/if}
        {if $user->icq}
        <tr>
          <td>ICQ:</td>
          <td>{$user->icq}</td>
        </tr>
        {/if}
        {if $user->home_site}
        <tr>
          <td>Личный сайт:</td>
          <td><a href="{$user->home_site}">{$user->home_site}</a></td>
        </tr>
        {/if}
        <tr><td><br/></td></tr>
        {if $user->about}
        <tr>
          <td valign="top">О себе:</td>
          <td>{$user->about}</td>
        </tr>
        {/if}
  </tbody>
</table>
{if $petsCount > 0}
<div class="window pets">
        <div class="window-head">
                <p class="window-title">Любимцы</p>
                <p class="window-info">(всего: {$petsCount})</p>
                <a href="/pet/{$user->user_id}" class="window-link">все</a>
                {if !Yii::app()->user->isGuest && $isAuthor == true}
                <a href="/pet/create" class="window-link">+ добавить</a>
                {/if}
        </div>
        <div class="window-content">
                {foreach from=$pets item=pet}
                <div class="pet">
                        <a href="/pet/view/{$pet->pet_id}">
                            {assign var="avatarSrc" value=UploadImageFacade::resolveImagePath($pet->avatar_id, "84x123")}
                            <img src="{$avatarSrc}" alt="" width="84" height="123" />
                        </a>
                        <p class="name">{$pet->nickname}</p>
                        <a href="">{$pet->type}</a>
                        <a href="">{$pet->race}</a>
                </div>                
                {/foreach}
        </div>
        <div class="window-bottom-left">
                <div class="window-bottom-right">
                </div>
        </div>
</div>
{/if}

{if $friendsCount > 0}
<div class="window friends">
    <div class="window-head">
            <p class="window-title">Друзья</p>
            <p class="window-info">( всего: {$friendsCount}
            {if ($isAuthor && $waitFriendsCount > 0)}
            , хотят дружить: {$waitFriendsCount}
            {/if})</p>
            <a href="/friend/{$user->user_id}" class="window-link">все</a>
    </div>
    <div class="window-content">            
            {foreach from=$friends item=friend}
            {assign var=friendUser value=UserFacade::getUserById($friend->user_id)}
            {assign var="avatarSrc" value=UploadImageFacade::resolveImagePath($friendUser->avatar_id, "84x123")}
            <div class="friend">
                    <a href="/user/{$friendUser->user_id}"><img src="{$avatarSrc}" alt="" /></a><br />
                    <a href="/user/{$friendUser->user_id}">{$friendUser->name}<br /> {$friendUser->surname}</a>
            </div>            
            {/foreach}            
    </div>
    <div class="window-bottom-left">
            <div class="window-bottom-right">
            </div>
    </div>
</div>
{/if}

{if ($postsCount > 0)}
<div class="window blog">
        <div class="window-head">
                <p class="window-title">Блог</p>
                <p class="window-info">(всего постов: {$postsCount})</p>
                <a href="/post/{$user->user_id}" class="window-link">все</a>
                {if !Yii::app()->user->isGuest && $isAuthor == true}
                <a href="/post/create/" class="window-link">+ добавить пост</a>
                {/if}
        </div>
        <div class="window-content">
                {foreach from=$posts item=post}
                <div class="post">
                        <a href="/post/view/{$post->post_id}" class="title">{$post->title}</a>
                        <p class="date">{$post->publish_date|date_format:"%e.%m.%Y %H:%M"}</p>
                        <p class="text">{$post->short_description}</p>
                        <a href="/post/view/{$post->post_id}" class="more">Подробнее</a>
                </div>
                {/foreach}
        </div>
        <div class="window-bottom-left">
                <div class="window-bottom-right">
                </div>
        </div>
</div>
{/if}

{userQuestionWidget userId=$user->user_id count=3}

</div>